package com.ohs.dal.dao.impl;

import java.util.List;

import com.ohs.dal.dao.AccountDAO;
import com.ohs.dal.model.Account;
import com.ohs.dal.model.Entity;
import com.ohs.dal.model.Room;
import com.ohs.dal.model.Specialty;

public class AccountDAOImpl extends AbstractDAOImpl<Account> implements AccountDAO {

	public void add(Account entity) {
	 	getHibernateTemplate().save(entity);
	}

	public Account get(String username) {
		return (Account) getHibernateTemplate().get(Account.class, username);
	}
	
	public Account getByEmail(String email) {
		return (Account) getHibernateTemplate().find("from " + Account.class.getName() + " a where a.email='" + email + "'").get(0);
	}

	public List<Account> list() {
		return getHibernateTemplate().find("from " + Account.class.getName());
	}

	public List<Specialty> getAllSpecialty() {
		return getHibernateTemplate().find("from " + Specialty.class.getName() + " s order by s.name asc");
	}

	public Specialty getSpecialty(long specialtyId) {
		return (Specialty) getHibernateTemplate().get(Specialty.class, specialtyId);
	}
}
